#include "packetbasetester.h"


PacketBaseTester::PacketBaseTester(QObject *parent) : QObject(parent)
{
    client = new UdpClient(this, 1122);
    server = new UdpServer(this, 1122);

    client->start();
    server->start();
}

bool PacketBaseTester::readFromFile(QString path)
{
    QFile file(path);
    if (!file.open(QIODevice::ReadOnly)) {
        return false;
    }

    data = file.readAll();

    packet.decode(data);

    return true;
}

void PacketBaseTester::encodePacket()
{
    packet.resetData();
    packet.setCoordinate(1271234567, 341234567);
    packet.setDepth(12345);

    qDebug() << packet.encode();
}

void PacketBaseTester::decodePacket()
{
    packet.setCoordinate(0, 0);
    packet.setDepth(0);

    qDebug() << packet.decode();
}

void PacketBaseTester::sendPacket()
{
    client->sendSingleMessage(packet.encode());
}
